<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="reportTitle" value="备品备件报表" />

<%@ include file="/common/report_head.jsp" %>
<%@ include file="/condition/sartTime_input.html"%>
<%@ include file="/condition/endTime_input.html"%>
<%@ include file="/condition/fab_sumo.html"%>
<%@ include file="/condition/mtrlProdId_text.html"%>
<%@ include file="/condition/summaryOrDetail_radio.html"%>

<%@ include file="/common/report_middle.jsp" %>
<div class="col-md-12" style="height: 820px;">
    <div id="pqGrid"></div>
</div>
<%@include file="/common/report_end.jsp" %>


<script>
    $(document).ready(function () {
        $("title").text("备品备件报表");

        $('#query_btn').click(function (){
            initGridAndChart();
            ajax('/jn-report/report/material_report.do' ,loadConditionMapData(), true, ajax_successful);

            function ajax_successful(outTrxObj) {
                if(outTrxObj.gridData.length < 1) { showMessengerDialog("数据查询为空"); return false; }

                //grid表格数据
                var colM;
                if ($.trim($("#summaryOrDetailRadio input:checked").val()) == "SUMMARY") {
                    colM = [
                        {halign:"center",align:'center', dataIndx: 'mtrl_prod_id_fk',   title: '物料代码',	    width: 180,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_name',         title: '物料名称',	    width: 550,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_spec',		    title: '物料规格',	    width: 480,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_unit',		    title: '物料单位',	    width: 130,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'relate_mtrl_qty',	title: '领用数量',	    width: 130,   editable: false, sortable: true}
                    ];
                }else if ($.trim($("#summaryOrDetailRadio input:checked").val()) == "DETAIL") {
                    colM = [
                        {halign:"center",align:'center', dataIndx: 'apply_date',	    title: '申请年月日',    width: 120,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'apply_time',	    title: '申请时间',      width: 100,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'fab_id',            title: '厂别',	        width: 130,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'fab_id_fk',         title: '厂别',	        width: 130,   editable: false, sortable: true, hidden: true},
                        {halign:"center",align:'center', dataIndx: 'apply_usr',         title: '申请人',	    width: 110,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'apply_usr_name',    title: '申请人姓名',	width: 110,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'requisition_id',    title: '申请单号',	    width: 130,   editable: false, sortable: true},
                        //{halign:"center",align:'center', dataIndx: 'apply_stat',        title: '申请状态',	    width: 90,     editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_prod_id_fk',   title: '物料代码',	    width: 120,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_name',         title: '物料名称',	    width: 350,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_spec',		    title: '物料规格',	    width: 260,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'mtrl_unit',		    title: '物料单位',	    width: 90,     editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'relate_mtrl_qty',	title: '领用数量',	    width: 90,     editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'agree_timestamp',	title: '申请同意时间',  width: 190,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'comp_timestamp',	title: '设备确认时间',	width: 190,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'evt_note',		    title: '申请原因',	    width: 200,   editable: false, sortable: true}
                    ];
                }
                _pqUtil.f.setColModel($("#pqGrid"), colM);
                if ($.trim($("#summaryOrDetailRadio input:checked").val()) == "SUMMARY") _pqUtil.f.seTitle($("#pqGrid"), "备品备件领用汇总");
                if ($.trim($("#summaryOrDetailRadio input:checked").val()) == "DETAIL") _pqUtil.f.seTitle($("#pqGrid"), "备品备件领用明细");
                _pqUtil.f.loadPqGridData($("#pqGrid"), outTrxObj.gridData);
            };
        });

    });
</script>
